<template>
<uni-shadow-root class="partials-chat_item-index"><view v-if="loginUser" class="chat_item" :style="'flex-direction:'+(loginUser.platformUser.id!=receiveData.fromUserId?'row':'row-reverse')+';text-align:'+(loginUser.platformUser.id!=receiveData.fromUserId?'left':'right')">
  <image :src="receiveData.fromUserIcon||"https://wx.qlogo.cn/mmopen/vi_32/DYAIOgq83eqE2ib7iaGACNGia4KaUOicxmULhqHugLrbR1LyO7edqtoDIzatw0srgufwu6hJNYgO5OovVGz9thL1fQ/132"" class="user_icon" :style="loginUser.platformUser.id!=receiveData.fromUserId?'margin-right:10rpx':'margin-left:10rpx'"></image>
  <view class="user_content" :style="loginUser.platformUser.id!=receiveData.fromUserId?'margin-left:10rpx':'margin-right:10rpx;background:#9eea6a'" v-if="receiveData.msgType==0">
    <image class="jiantou" :style="loginUser.platformUser.id!=receiveData.fromUserId?'left:-14rpx;transform:rotateY(180deg)':'right:-14rpx;transform:rotateY(0deg)'" :src="loginUser.platformUser.id!=receiveData.fromUserId?'https://image1.sansancloud.com/xianhua/2019_9/4/16/40/0_921.jpg?x-oss-process=style/preview_120':'https://image1.sansancloud.com/xianhua/2019_9/6/15/49/40_117.jpg?x-oss-process=style/preview_120'"></image>
    <text class="user_text" v-if="receiveData.content">{{receiveData.content}}</text>
    <text class="user_text" v-else :style="'color:#999;'+(loginUser.platformUser.id!=receiveData.fromUserId?'text-align:left;':'text-align:right;')">不支持显示</text>
  </view>
  <image mode="widthFix" @click.stop.prevent="lookBigImage" class="img_content" :src="receiveData.content" v-if="receiveData.msgType==1"></image>
</view></uni-shadow-root>
</template>

<script>

global['__wxRoute'] = 'partials/chat_item/index'
const app = getApp();
Component({
  properties: {
    receiveData: {
      type: JSON,
      value: 'default value',
    }
  },
  data: {
    someData: {},
    sysWidth:"",
  },
  ready:function(){
    let that=this;
    console.log("====chat-item====",that.data.receiveData)
    that.setData({
      loginUser: app.globalData.loginUser,
      setting:app.globalData.setting
    });
  },
  methods: {
    lookBigImage:function(){
      let that=this;
      console.log("===lookBigImage=====",)
      that.triggerEvent('resEvent',"") //myevent自定义名称事件，父组件中使用
    },
    buttom: function () {
      app.globalData.wxLogin(1011)
    },
    tolinkUrl: function (event) {
      console.log(event.currentTarget.dataset.link)
      app.globalData.linkEvent(event.currentTarget.dataset.link);
    }
  },
})
export default global['__wxComponents']['partials/chat_item/index']
</script>
<style platform="mp-weixin">
.chat_item{
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  margin: 20rpx 6rpx
}
.user_content{
  display: flex;
  flex-direction: row;
  max-width:74%;
  background:#fff;
  padding: 20rpx;
  box-sizing: border-box;
  border-radius: 10rpx;
  position: relative;
  min-height: 76rpx;
  min-width: 66rpx
}
.user_text{
  width: 100%;
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  text-align:left;
  overflow:hidden;
}
.user_icon{
  width: 76rpx;
  height: 76rpx;
  border-radius: 10rpx;
}
.jiantou{
  width: 20rpx;
  height: 20rpx;
  position: absolute;
  top: 28rpx;
  transform: rotateY(180deg)
}
.img_content{
  width: 200rpx;
  border-radius: 10rpx;
  background:#fff;
}
</style>